<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>

<head>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/MUI/css/mui.picker.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/resources/css/pagination.css">
<script
	src="${pageContext.request.contextPath}/resources/MUI/js/mui.picker.min.js"></script>
<script
	src="${pageContext.request.contextPath}/resources/js/pagination.js"></script>
</head>
<style>
.btn {
	line-height: 40px;
}
</style>

<body>
	<form class="mui-input-group mui-collapse-content">
		<div class="mui-input-row">
			<label>柜子ID:</label> <input type="text" class="caseNo"
				disabled="disabled"> <span class="must">不可修改</span>
		</div>
		<div class="mui-input-row">
			<label>使用时间:</label> <input id='end' data-options='{}'
				class="btn useEndTime" id="time" placeholder="开始时间">
		</div>
		<div class="mui-button-row">
			<a class="mui-btn mui-btn-primary submit">提交</a>
		</div>
	</form>
	<div class="table-list"></div>
	<div class="page pagination" id="pagination"></div>
	<script type="text/javascript">
        	mui('#offCanvasContentScroll').scroll().scrollTo(0,0);

        	$(".mui-title").html("修改柜子使用时间");
        	
			var useTime = sessionStorage.getItem('useTime');
			useTime = JSON.parse(useTime);
			$(".caseNo").attr("value",useTime.caseNo);
			$(".useEndTime").val(useTime.useTime);
			
			//时间
			var btns = $('.btn');
			var end = useTime.useTime;
			btns.each(function(i, btn) {
				btn.addEventListener('tap', function() {
					var _self = this;
						var optionsJson = this.getAttribute('data-options') || '{}';
						var options = JSON.parse(optionsJson);
						var id = this.getAttribute('id');
						_self.picker = new mui.DtPicker(options);
						_self.picker.show(function(rs) {
							end = rs.text+":00";
							$("#"+id).val(rs.text);
							_self.picker.dispose();
							_self.picker = null;
						});
					
				}, false);
			});

			$(".submit").on("touchstart",function(){
				var caseNo = $(".caseNo").val()

				$.post("/caseUseTime/setUseEndTime?caseNo="+caseNo+"&useEndTime="+end,function(res){
	    			if(res.success){
	    				mui.toast(res.message);
	    				history.back();
	    			}else{
	    				mui.toast(res.message);
	    			}
	    		}) 
			})
		</script>
</body>

</html>